package mannA1;

import java.util.ArrayList;
import java.util.Scanner;

import mannA1.model.Edge;
import mannA1.model.Line;
import mannA1.model.Model;
import mannA1.view.A1GUI;

/** Sets up the project, creating the Model and certain values. */
public class Main {

	/** Takes user input for number of Lines and rounds, must be between 3 and 8.  */
	public static void main (String args[])
	{
		int numLines = 0;
		int numRounds = 0;
		Line[] lines = null;
		ArrayList<Edge> edges = new ArrayList<Edge>();
		

		Scanner stdin = new Scanner(System.in);
		while (!isValid(numLines) || !isValid(numRounds)) {
			try {
				System.out.print("Number of lines: ");
				numLines = Integer.parseInt(stdin.nextLine());
				System.out.print("Number of rounds: ");
				numRounds = Integer.parseInt(stdin.nextLine());
			} catch (NumberFormatException e) {
				System.err.println(e.getMessage());
			}
		}
		
		int numEdges = (numLines * numRounds);

		
		lines = new Line[numLines];
		Model m = new Model(numLines, numRounds, lines, edges, numEdges);
		A1GUI gui = new A1GUI(m);
		gui.setVisible(true);
	}

	/** 
	 * isValid checks that the value input is between 3 and 8 inclusive.
	 */
	static boolean isValid (int i)
	{
		if (i >= 3 && i <= 8)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}
